import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

//此处用vuex做全局数据
const store = new Vuex.Store({
	state: {
		userInfo: uni.getStorageSync('userInfo') || {},
		userType: uni.getStorageSync('userType') || {}
	},
	mutations: {
		SET_USERINFO(state, userInfo) {
			uni.setStorageSync('userInfo', userInfo)
			state.userInfo = userInfo
		},
		SET_USERTYPE(state, userType) {
			uni.setStorageSync('userType', userType)
			state.userType = userType
		},
	}
})

export default store
